#include "CUDAAcceleration.h"
#include <XnCppWrapper.h>
#include <opencv2\opencv.hpp>
#include "thrust\fill.h"
#include "thrust\device_ptr.h"


class Segmentation_GPU{
public:	
	Segmentation_GPU(int width, int height);
	cv::Mat_<int>* segmentImage(xn::ImageMetaData* imageMD, float THRESHOLD = 2.0);
	int* getRawSegmentation();	

private:
	void initMemory();
	void copyInputImage(xn::ImageMetaData* imageMD);
	void smoothChannel();
	void runInitialSegmentation();
	void setOutputImage();
	
	void smoothChannels(float sigma);
	void postProcess();
	
	void displayFilteringResult();

	int width;
	int height;
	float THRESHOLD;
	int* clusterMap;
	float4* clusterMap_C;
	int* resultMap;
	cv::Mat_<cv::Vec3b> original;
	cv::Mat_<int> bw;
};
